<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class AdminSessionController extends BaseController {
    
    public function login() {
        
        if ( Auth::check() ) {
            return Redirect::to('at-admin');
        }
        
        return View::make('admin/user/login');
    }
    
    public function postSignin() {
        
        if ( Auth::check() ) {
            return Redirect::to('at-admin');
        }
        
        $rememberMe = false;
        
        if (Auth::attempt(array(
                'email'    =>Input::get('email'), 
                'password' =>Input::get('password'), 
                'active'   => 1,
                'admin'    => 1,
                'trash'    => 0, 
            ), TRUE)) {
            
            return Redirect::to('at-admin')->with('message', 'You are now logged in!');
        } else {  
            
            return Redirect::to('at-admin/user/login')
                ->with('message', 'Your username/password combination was incorrect')
                ->withInput();
        }
    }
    
}